package com.dys.designpattern.simplefactory.distributeprizestosimplefactories.controller;

import com.dys.designpattern.simplefactory.distributeprizestosimplefactories.entity.AwardInfo;
import com.dys.designpattern.simplefactory.distributeprizestosimplefactories.factory.FreeGoodsFactory;
import com.dys.designpattern.simplefactory.distributeprizestosimplefactories.service.IFreeGoods;
import com.dys.designpattern.simplefactory.distributeprizestosimplefactories.vo.ResponseResult;

/**
 * @Author: 疾风
 * @ClassName: DeliverController
 * @Description: 按照类型的不同发放商品：奖品类型: 1 打折券 ,2 优酷会员,3 小礼品
 * @CreateDate: 2024/05/13
 * @Version: v1.0.0
 */
public class DeliverController {

    public ResponseResult awardInfo(AwardInfo awardInfo) {
        try {
            IFreeGoods iFreeGoods = FreeGoodsFactory.getInstance(awardInfo.getAwardType());
            ResponseResult responseResult = iFreeGoods.sendFreeGoods(awardInfo);
            return responseResult;
        }catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult("201","奖品发放失败!");
        }
    }
}
